package com.timesheet.server.core.mapper;

import java.lang.reflect.InvocationTargetException;

import com.timesheet.server.common.models.TaskDTO;

import org.apache.commons.beanutils.PropertyUtils;

public class Mapper3 {

	public static <T, U> T map(T destination, U source) {
		try {

			PropertyUtils.copyProperties(destination, source);
			return destination;
		}
		catch (IllegalAccessException e) {

			e.printStackTrace();
		}
		catch (InvocationTargetException e) {

			e.printStackTrace();
		}
		catch (NoSuchMethodException e) {

			e.printStackTrace();
		}
		return null;
	}

	public static void main(String[] args) {

		TaskDTO dest = new TaskDTO();

		TaskDTO source = new TaskDTO();
		source.setTaskDescription("dkdkd");

		TaskDTO dto = Mapper3.map(dest, source);
		System.out.println(dto.getTaskDescription());

	}

}
